package com.right.health.app.ui.me.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.magic.basic.adapter.BaseAbsAdapter;
import com.right.health.app.R;
import com.right.health.app.app.App;
import com.right.health.app.bean.VisitCardResponse;
import com.right.health.app.constants.AppConfig;
import com.right.health.app.utils.GlideUtil;

/*
 * Created by hopeliao on 2019-09-24
 *
 */
public class MeVisitCardAdapter extends BaseAbsAdapter<VisitCardResponse.VisitCardInfo> {

    private View.OnClickListener mClickListener;

    public void setOnClickListener(View.OnClickListener listener) {
        this.mClickListener = listener;
    }

    public MeVisitCardAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.me_visit_card_item, null);
            viewHolder = new ViewHolder();
            viewHolder.contentImage = (ImageView) convertView.findViewById(R.id.iv_content);
            viewHolder.nameTv = (TextView) convertView.findViewById(R.id.tv_name);

           viewHolder.tipsTv = (TextView) convertView.findViewById(R.id.tv_tips);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        VisitCardResponse.VisitCardInfo info = mDataSource.get(position);

        viewHolder.nameTv.setText(info.syscommunityname);
        viewHolder.tipsTv.setText(String.format("就诊卡号：%s", info.healthcardno));

        Log.e("TAG", "url = " + (AppConfig.PHOTO_URL + info.hospitalpic));
        Glide.with(App.getInstance()).load(AppConfig.PHOTO_URL + info.hospitalpic).apply(GlideUtil.getRoundOption()).into(viewHolder.contentImage);
        return convertView;
    }

    private class ViewHolder {
        private ImageView contentImage;
        private TextView nameTv;
        private TextView tipsTv;
    }
}
